#ifndef MYTABLELIST_H
#define MYTABLELIST_H

#include <QAbstractTableModel>
#include <QVector>
#include <QString>

struct ScheduleItem {
    QString date;
    QString event;
};

class myTablelist : public QAbstractTableModel {
    Q_OBJECT
public:
    explicit myTablelist(QObject* parent = nullptr);

    // QAbstractTableModel overrides
    int rowCount(const QModelIndex &parent = QModelIndex()) const override;
    int columnCount(const QModelIndex &parent = QModelIndex()) const override;
    QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
    void clear(); // 清空所有数据
    // Custom functions
    // 声明数据操作方法（需要新增的代码）
        void addSchedule(const ScheduleItem &item); // 添加日程
        void removeSchedule(int row); // 删除指定行
        void updateSchedule(int row, const ScheduleItem &item); // 更新指定行
    ScheduleItem getItem(int row) const;
    const QVector<ScheduleItem>& getAllItems() const;

private:
    QVector<ScheduleItem> scheduleList;
};

#endif // MYTABLELIST_H
